﻿# -*- coding: utf-8 -*-
"""
Created on Fri Jun 28 15:05:42 2024
@author: Administrator
"""
import arcpy
#arcpy.env.workspace = u"C:/Users/Administrator/Desktop/1109/77/两市六县区数据矢量/610112未央区国土空间总体规划矢量数据.gdb"
arcpy.env.workspace = arcpy.GetParameterAsText(0)
bsm_1 = arcpy.GetParameterAsText(1)
datasets = arcpy.ListDatasets(feature_type='feature')  #获取数据集列表
#遍历数据集
#bsm_1 = '610112'
start_bh = 100000001

for ds in datasets:
	tt = arcpy.ListFeatureClasses(feature_dataset=ds)
	for fc in tt:
		desc = arcpy.Describe(fc)
		name = desc.name  #获取要素类名称
		fc_aliasname = desc.aliasName  #获取要素类别名
		inFeature = arcpy.env.workspace + '/' + ds + '/' + name
		fieldList = arcpy.ListFields(inFeature)
		#field_name = []
		with arcpy.da.UpdateCursor(inFeature, ["BSM"]) as cursor:
			for row in cursor:
				#从1开始编号
				row[0] = bsm_1 + '0000' + str(start_bh)[1:]
				start_bh += 1
				cursor.updateRow(row)
				arcpy.AddMessage(u"正在编{0}的第{1}个要素的标识码！".format(name,str(start_bh)[1:]))

#获取要素个数
#fe_sum = int(arcpy.management.GetCount(inFeature)[0])
#构造一个1-1000的列表
#sequence = [i for i in range(1,1001)]



